@extends('admin.layouts')

@section('style')
<style>

</style>
@endsection

@section('main')
    <div class="container-fluid larry-wrapper">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12">
                <section class="panel panel-padding">
                    <form id="form1" class="layui-form layui-form-pane" action="{{url('admin/roleset')}}">
                        {{csrf_field()}}
                        <input type="hidden" name="id" value="{{$role->id}}">
                        <div class="layui-form-item ">
                            <div class="layui-form-item">
                                <label class="layui-form-label">{{trans('config.role')}}</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" value="{{$role->name}}" disabled autocomplete="off" class="layui-input layui-disable">
                                </div>
                            </div>

                            <div class="layui-form-item permission-list">
                                <label class="layui-form-label">{{trans('config.haverole')}}</label>
                                <div class="layui-input-block layui-text-left">
                                    <ul>
                                        @foreach($data as $r)
                                            <li class="layer-li">
                                                <input type="checkbox" name="per_id[{{$r->id}}]" @if(in_array($r->id,$child)) checked="checked"  @endif value="{{$r->id}}" title="{{$r->name}}" lay-filter="role" />
                                                @if(count($r->sub)>0)
                                                    @foreach($r->sub as $v)
                                                    <dl class="layer-dl-inline clearfix">
                                                        <input type="checkbox" name="per_id[{{$v->id}}]" @if(in_array($v->id,$child)) checked="checked"  @endif value="{{$v->id}}" title="{{$v->name}}" lay-filter="role" />
                                                        @if(count($v->sub)>0)
                                                            <div class="clear"></div>
                                                            @foreach($v->sub as $m)
                                                                <dd><input type="checkbox" name="per_id[{{$m->id}}]" @if(in_array($m->id,$child)) checked="checked"  @endif value="{{$m->id}}" title="{{$m->name}}" lay-filter="role" /></dd>

                                                                @foreach($m->sub as $n)
                                                                    <dd><input type="checkbox" name="per_id[{{$n->id}}]" @if(in_array($n->id,$child)) checked="checked"  @endif value="{{$n->id}}" title="{{$n->name}}" lay-filter="role" /></dd>
                                                                @endforeach
                                                            @endforeach
                                                            <div class="clear"></div>
                                                        @endif
                                                    </dl>
                                                    @endforeach
                                                @endif
                                            </li>
                                        @endforeach
                                    </ul>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" jq-submit jq-filter="submit">{{trans('config.btn_submit')}}</button>
                            </div>
                        </div>
                    </form>
                </section>
            </div>
        </div>
    </div>
@endsection

@section('script')
<script>
    layui.use('role');
</script>
@endsection